<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .box {
            width: 100px;
            height: 100px;
            background-color: red;
            transition: background-color 1s;
        }

        .box:hover {
            background-color: blue;
        }

        .box.active {
            background-color: green;
        }
    </style>

</head>
<body>
<div class="box" onclick="toggleActive()"></div>
<script>
    function toggleActive() {
        var box = document.querySelector('.box');
        box.classList.toggle('active');
    }
</script>
</body>
</html>